<!--
 * @Description  : tables
 * @Autor        : 杜康
 * @Date         : 2023-03-06 17:26:09 +0800
 * @LastEditors  : 杜康
 * @LastEditTime : 2024-11-05 10:41:30 +0800
-->
<template>
  <el-form :inline="true" :model="formInline">
    <el-form-item label="关键词">
      <el-input v-model="formInline.user" placeholder="请输入关键词" clearable />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">查询</el-button>
      <el-button type="success" @click="onSubmit">新增</el-button>
    </el-form-item>
  </el-form>
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" />
  </el-table>
  <div class="pagination">
    <el-pagination
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[100, 200, 300, 400]"
      :size="size"
      background
      layout="total, sizes, prev, pager, next"
      :total="400"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup>
import { ref } from "vue";
const formInline = ref({
  user: "",
  region: "",
  date: ""
});

const onSubmit = () => {
  console.log("submit!");
};
const tableData = ref([
  {
    date: "2016-05-03",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date: "2016-05-02",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date: "2016-05-04",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles"
  },
  {
    date: "2016-05-01",
    name: "Tom",
    address: "No. 189, Grove St, Los Angeles"
  }
]);

const currentPage = ref(4);
const pageSize = ref(100);

const handleSizeChange = (val) => {
  console.log(`${val} items per page`);
};
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`);
};
</script>

<style lang="less" scoped>
.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: end;
}
</style>
